/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package user_gui;

import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.SwingWorker;

/**
 *
 * @author Jônatas
 */
public class TaskList {

    private List<ProgressBarFrame> tasks;

    public TaskList(List<ProgressBarFrame> tasks) {
        this.tasks = tasks;

    }

    @SuppressWarnings("SleepWhileHoldingLock")
    public void execute() {

        for (int i = 0; i < tasks.size(); i++) {

            ProgressBarFrame frame = tasks.get(i);
            frame.setVisible(true);
            frame.execute();
            try {
                frame.getTask().get();
            } catch (InterruptedException ex) {
                Logger.getLogger(TaskList.class.getName()).log(Level.SEVERE, null, ex);
            } catch (ExecutionException ex) {
                Logger.getLogger(TaskList.class.getName()).log(Level.SEVERE, null, ex);
            }

        }
    }
}
